#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "hpcr_types.h"
#include "core/hpcr_map.h"

int main()
{
    Map *map = MapInit();
    MapValue *mapValue = (MapValue *)malloc(sizeof(MapValue));
    mapValue->type = MAP_VALUE_TYPE_DOUBLE;
    mapValue->value = malloc(sizeof(double));
    *(double *)(mapValue->value) = 78.123;
    MapPut(map, MapItemInit("Weight", mapValue));

    mapValue = (MapValue *)malloc(sizeof(MapValue));
    mapValue->type = MAP_VALUE_TYPE_LONG;
    mapValue->value = malloc(sizeof(hpcr_int64_t));
    *(hpcr_int64_t *)(mapValue->value) = 17879386605;
    MapPut(map, MapItemInit("Phone", mapValue));

    mapValue = (MapValue *)malloc(sizeof(MapValue));
    mapValue->type = MAP_VALUE_TYPE_STRING;
    mapValue->value = malloc(sizeof(char) * 20);
    strcpy((char *)(mapValue->value), "Su wenyang");
    MapPut(map, MapItemInit("Name", mapValue));

    mapValue = (MapValue *)malloc(sizeof(MapValue));
    mapValue->type = MAP_VALUE_TYPE_ARRAY;

    MapArray *mapArray = MapArrayInit();
    mapArray->cap = 12;
    mapArray->len = 12;
    mapArray->type = MAP_VALUE_TYPE_DOUBLE;
    mapArray->array = (double *)malloc(sizeof(double) * 12);
    for (int i = 0; i < 12; i++)
    {
        ((double *)mapArray->array)[i] = i * 1012.213;
    }
    mapValue->value = mapArray;
    MapPut(map, MapItemInit("Salary", mapValue));

    printf("%s\n", MapString(map, NULL));
    free(map);
    return 0;
}